package com.zh.rent.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zh.rent.dao.UserDao;
import com.zh.rent.pojo.User;
import com.zh.rent.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class IUserServiceImpl implements IUserService {
    @Autowired
    UserDao userDao;
    @Override
    public PageInfo<User> selUserAll(Integer pageNum, Integer pageSeiz, Map<String,Object> map) {
        List<User> users = userDao.selUserAll(map);
        PageHelper.startPage(pageNum,pageSeiz);

        return new PageInfo<>(users);
    }

    @Override
    public int selUser(User user) {
        try {
            User user1 = userDao.selUser(user);
            if(user1 ==null){
               return 0;
            }
        }catch (Exception e){
            return 0;
        }
        return 1;
    }

    @Override
    public Integer intsetUser(User user) {
        Integer i= userDao.intsetUser(user);
        return i;
    }

    @Override
    public int updateNum(User user) {
        return userDao.updateNum(user);
    }

    @Override
    public int deluserAll(List<Integer> list) {
        return userDao.deluserAll(list);
    }

    @Override
    public int deluser(int userid) {
        return userDao.deluser(userid);
    }
}
